package com.ascentive.finallyfast;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;

import com.ascentive.finallyfast.deepclean.DeepCleanPage;
import com.ascentive.finallyfast.quickboost.QuickBoostPage;

public class MainScreenActivity extends TabActivity{

	TabHost tabHost;
	int currentTabHost = 0;
	
	/** Called when the activity is first created. */
	// @Override
	public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	 Resources res = getResources(); // Resource object to get Drawables
     tabHost = getTabHost();  // The activity TabHost
     TabHost.TabSpec spec;  // Resusable TabSpec for each tab
     Intent intent;  // Reusable Intent for each tab
     
     intent = new Intent().setClass(this, QuickBoostPage.class);
     spec = tabHost.newTabSpec("Quick_Boost").setIndicator("Quick Boost",
                       res.getDrawable(R.drawable.quickboost_normal48x48))
                   .setContent(intent);
     tabHost.addTab(spec);
     
  // Create an Intent to launch an Activity for the tab (to be reused)
     //intent = new Intent().setClass(this, DeepCleanList.class);
     intent = new Intent().setClass(this, DeepCleanPage.class);
     // Initialize a TabSpec for each tab and add it to the TabHost
     spec = tabHost.newTabSpec("Deep_Clean").setIndicator("Deep Clean",
                       res.getDrawable(R.drawable.deepclean_normal48x48))
                   .setContent(intent);
     tabHost.addTab(spec);
     
     
     
     TabHost tabhost = getTabHost();
     for(int i=0;i<tabhost.getTabWidget().getChildCount();i++) 
     {
         tabhost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_bg);
         TextView tv = (TextView) tabhost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
         tv.setTextColor(Color.WHITE);
     }
     TextView tv = (TextView) tabhost.getCurrentTabView().findViewById(android.R.id.title); //for Selected Tab
     // tabhost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_bg);
     // tv.setTextColor(Color.BLACK);
     
     restoreMe();
     FinallyFastApplication ffApp = (FinallyFastApplication)getApplication();
     tabHost.setCurrentTab(ffApp.getFirstSelectedTab());
     
	}
	
	 @Override 
     public void onConfigurationChanged(Configuration newConfig) { 
       //ignore orientation change 
       super.onConfigurationChanged(newConfig); 
     }
	 
	 @Override
	 public Object onRetainNonConfigurationInstance() {
	  		return(tabHost.getCurrentTab());
	  	}
	 
	 private void restoreMe() {
	  		
		 // contact=null;
	  
	  		if (getLastNonConfigurationInstance() != null) {
	  			currentTabHost = (Integer)getLastNonConfigurationInstance();
	  		}
	  }
}
